<template>
  <div>
    <common-upload-file
      v-model="files"
      :max="9"
      uploadType="file"
      showFileList
      accept=".doc,.docx,.xlsx,.xls,.jpg,.jpeg,.png"
      @onSuccess="onChange"
    ></common-upload-file>
  </div>
</template>

<script>
import _clonedeep from 'lodash.clonedeep'
import CommonUploadFile from '@/components/common-upload-file/index.vue'

export default {
  components: {
    CommonUploadFile,
  },
  props: {
    list: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      files: [],
    }
  },
  computed: {},
  watch: {
    list: {
      handler(val) {
        this.files = _clonedeep(val)
      },
      immediate: true,
    },
  },
  methods: {
    onChange() {
      this.$emit('change', _clonedeep(this.files))
    },
  },
}
</script>

<style lang="less" scoped></style>
